import { Event } from "../../utils/interface";
import { observer } from "../../utils/observer";

// components/tab/tab.js
let tabList: string[] = [];
let active: string = "";
let data = {
  tabList,
  active,
};
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    active: {
      type: String,
      value: "体验问题",
    },
    tabList: {
      type: Array,
      valule: [],
    },
  },
  lifetimes: {
    attached() {
      data = observer(this.data, this);
    },
  },

  /**
   * 组件的初始数据
   */
  data,

  /**
   * 组件的方法列表
   */
  methods: {
    changeTab(e: Event<{ item: string }>) {
      const str = e.currentTarget.dataset.item;
      data.active = str;
      this.triggerEvent("change", str);
    },
  },
});
